/*
 * Bucket.h
 *
 *  Created on: 11/10/2011
 *      Author: gisedaye
 */

#ifndef BUCKET_H_
#define BUCKET_H_
#include <vector>
#include "exceptions/ExceptionNotFound.h"
#include "exceptions/ExceptionExists.h"
#include "../common/Record.h"
#include "utils/FileLoader.h"
#include "utils/FileWritable.h"
#include "../../util/Utils.h"

#define BUCKET_SIZE 256

using namespace std;

class Bucket {
private:
	vector <Record*> records;
	int dispersionNumber;
	int bucketNumber;

public:
	Bucket(int bucketNumber);
	void insertRecord(Record * record, bool * overflow);
	void modifyRecord(Record * record, bool * overflow);
	void deleteRecord(Record * record, bool * underflow);
	int getBucketSize();
	void writeToFile(string filename);
	string getRecordsAsString();
	int getPosition(string id);
	bool recordExists(string id);
	void loadBucket(string filename, int bucketNumber);
	void loadStringToClass(string bucketString);
	void loadRecordsToClass(string recordsString);
	bool isOverflow();
	bool isUnderflow();
	virtual ~Bucket();
    int getDispersionNumber();
    vector<Record*> getRecords();
    void setDispersionNumber(int dispersionNumber);
    void setRecords(vector<Record*> records);
    int getBucketNumber();
    void setBucketNumber(int bucketNumb);

};

#endif /* BUCKET_H_ */
